#!/bin/bash
# Program:
#	User input a file, program will check the following:
#	1.) exist? 2.) file/directory? 3.) file permissions
# History:
# 2015/10/30 Leonardo First release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

echo -e "Please input a filename, I will check the filename's type and \
permission. \n\n"

read -p "Input a filename: " filename
test -z $filename && echo "You MUST input a filename." && exit 0

test ! -e $filename && echo "The filename '$filename' DO NOT exist" && exit 0

test -f $filename && filetype="regulare file"
test -d $filename && filetype="directory"
test -r $filename && permission=" readable"
test -w $filename && permission="$permission writable"
test -x $filename && permission="$permission executable"

echo "The file: $filename is a $filetype."
echo "And the permissions are:$permission."

